//
//  HKListCellModel.m
//  KSBridgeDesign
//
//  Created by huzhaoke on 2021/4/13.
//

#import "HKListCellModel.h"
#import "HKListCellModel+Private.h"

@interface HKListCellModel ()

@property (nonatomic, copy, readwrite) NSString *identifier;

@end

@implementation HKListCellModel
#pragma mark - publicMethod
- (NSString *)identifier {
    return NSStringFromClass(self.cellClass);
}

#pragma mark - Reload
- (void)reloadWithAnimation:(UITableViewRowAnimation)animation {
    [self reloadWithAnimation:animation completion:nil];
}

- (void)reloadWithAnimation:(UITableViewRowAnimation)animation completion:(void (^)(BOOL isFinished))completion{
    //  cellItem正在渲染中(此时不再需要重复更新)
    if (self.isReloading) {
        return;
    }
    if (self.reloadBlock) {
        self.reloadBlock(self, self.indexPath, animation,^(BOOL isFinished){
            if (completion) {
                completion(isFinished);
            }
        });
    }
}

- (void)reload {
    [self reloadWithAnimation:UITableViewRowAnimationNone];
}

#pragma mark - publicMethod
- (NSIndexPath *)cellIndexPath {
    return self.indexPath;
}

#pragma mark - properties
- (HKListCellModelContext *)context {
    if (!_context) {
        _context = [HKListCellModelContext new];
    }
    return _context;
}

@end
